home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_mysql.idb / usr / freeware / include / mysql / my_list.h.z / my_list.h
C/C++ Source or Header  |  2002-10-07  |  2KB  |  48 lines

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This library is free software; you can redistribute it and/or
  4.    modify it under the terms of the GNU Library General Public
  5.    License as published by the Free Software Foundation; either
  6.    version 2 of the License, or (at your option) any later version.
  7.    
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU Library General Public
  14.    License along with this library; if not, write to the Free
  15.    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16.    MA 02111-1307, USA */
  17.  
  18. #ifndef _list_h_
  19. #define _list_h_
  20.  
  21. #ifdef    __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. typedef struct st_list {
  26.   struct st_list *prev,*next;
  27.   void *data;
  28. } LIST;
  29.  
  30. typedef int (*list_walk_action)(void *,void *);
  31.  
  32. extern LIST *list_add(LIST *root,LIST *element);
  33. extern LIST *list_delete(LIST *root,LIST *element);
  34. extern LIST *list_cons(void *data,LIST *root);
  35. extern LIST *list_reverse(LIST *root);
  36. extern void list_free(LIST *root,pbool free_data);
  37. extern uint list_length(LIST *list);
  38. extern int list_walk(LIST *list,list_walk_action action,gptr argument);
  39.  
  40. #define rest(a) ((a)->next)
  41. #define list_push(a,b) (a)=list_cons((b),(a))
  42. #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); }
  43.  
  44. #ifdef    __cplusplus
  45. }
  46. #endif
  47. #endif
  48.